﻿using Digitalmes.Infrastructure.Data;
using Digitalmes.Infrastructure.MessageBrokers;

namespace Digitalmes.Infrastructure;

public static class DependencyInjection
{
    /// <summary>
    /// 注册基础设施服务。
    /// </summary>
    public static IHostBuilder UseInfrastructureSetup(this IHostBuilder builder)
    {
        builder.ConfigureServices((hostBuilder, services) =>
        {
            services.AddMemoryCache();
            services.AddSingleton(TimeProvider.System);

            // 注册基础服务
            services.AddUniqueSetup();
            services.AddSqlSugarSetup(hostBuilder);
            services.AddMessageQueueSetup();
            services.AddIOSetup();
            services.AddJobSetup(hostBuilder.Configuration);
        });

        builder.AddScada();

        return builder;
    }
}
